<?php

?>

<div class="left_category_area">
    <ul>
        <?php

            if($template->get('aRootCategories'))
            {
                $aRootCategory = $template->get('aRootCategory');
                foreach($template->get('aRootCategories') as $aCategory)
                {
                    // Show root cattegory
                    if($aCategory['uri'] == $template->get('sCurrentUri'))
                    {
                        echo '<li class="active_category"><a href="'.$aCategory['uri'].'">'.$aCategory['name'].'</a></li>';
                        if($template->get('aSubCategoriesOfCurrent'))
                        {
                            echo "<ul>";
                            foreach($template->get('aSubCategoriesOfCurrent') as $aMySubCategory)
                            {
                                // Show all sub category of current category
                                echo '<li><a href="'.$aMySubCategory['uri'].'">'.$aMySubCategory['name'].'</a></li>';
                            }
                            echo "</ul>";
                        }
                    }
                    else
                    {
                        echo '<li><a href="'.$aCategory['uri'].'">'.$aCategory['name'].'</a></li>';
                    }
                    if($template->get('pCategories'))
                    {
                        $aPcategoriesTemp = $template->get('pCategories');
                        if($aCategory['uri'] == $aRootCategory['uri'])
                        {
                            for($i=1 ; $i < count($template->get('pCategories')); $i++)
                            {
                                // Show all parent category
                                echo "<ul>";
                                echo '<li><a href="'.$aPcategoriesTemp[$i]['uri'].'">'.$aPcategoriesTemp[$i]['name']."</a></li>";
                            }
                            if($template->get('subCategory'))
                            {
                                echo "<ul>";
                                foreach($template->get('subCategory') as $aSubCategory)
                                {
                                    if($aSubCategory['uri'] == $template->get('sCurrentUri'))
                                    {
                                        // Show all sub category of closest parent category
                                        echo '<li class="active_category"><a href="'.$aSubCategory['uri'].'">'.$aSubCategory['name'].'</a></li>';
                                        if($template->get('aSubCategoriesOfCurrent'))
                                        {
                                            echo "<ul>";
                                            foreach($template->get('aSubCategoriesOfCurrent') as $aMySubCategory)
                                            {
                                                // Show all sub category of current category
                                                echo '<li><a href="'.$aMySubCategory['uri'].'">'.$aMySubCategory['name'].'</a></li>';
                                            }
                                            echo "</ul>";
                                        }
                                    }
                                    else
                                    {
                                        echo '<li><a href="'.$aSubCategory['uri'].'">'.$aSubCategory['name'].'</a></li>';
                                    }
                                }
                                echo "</ul>";
                            }
                            for($i=1 ; $i < count($template->get('pCategories')); $i++)
                            {
                                echo "</ul>";
                            }
                        }
                    }
                }
            }
        ?>
    </ul>
</div>